package com.xunyin.modules.goods.rest;

import com.xunyin.api.ApiResult;
import com.xunyin.common.interceptor.AuthCheck;
import com.xunyin.modules.log.AppLog;
import com.xunyin.modules.goods.service.TGoodsService;
import com.xunyin.modules.goods.service.param.GoodsOrderParam;
import com.xunyin.modules.goods.vo.GoodsInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 茶室柜台商品控制器
 * </p>
 *
 * @author admin
 * @since 2022-10-28
 */
@Slf4j
@RestController
@Api(value = "茶室柜台商品", tags = "共享空间:茶室柜台商品")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class GoodsController {

    TGoodsService tGoodsService;

    /**
     * 根据 linkId 获取商品信息
     */
    @AppLog(value = "根据 linkId 获取商品信息", type = 1)
    @AuthCheck
    @PostMapping("/getGoodsByLinkId")
    @ApiOperation(value = "根据 linkId 获取商品信息", notes = "根据 linkId 获取商品信息")
    public ApiResult<GoodsInfoVo> getGoodsByLinkId(@Validated @RequestBody GoodsOrderParam param) {
        log.info("getGoodsByLinkId -> GoodsOrderParam = {}", param.toString());
        return ApiResult.ok(tGoodsService.getGoodsByLinkId(param.getGoodsLinkId()));
    }


}
